<?php
    class Contenu_m extends Model{
        function Contenu_m(){
            parent::Model();
            $this->load->database();
            $this->load->library('pagination');
        }
        function get_all_contents($per_page,$off_set){
            $this->db->select();
            $this->db->from('content');
            $this->db->order_by('id_content','DESC');
            $this->db->limit($per_page,$off_set);
            $query = $this->db->get();
            return $query->result_array();    
        }
        function delete_content($id){
            return $this->db->delete('content',array('id_content'=>$id));
        }
        function post_content($data){
            return $this->db->insert('content',$data);
        }
        function get_content_by_id($id){
            $query = $this->db->get_where('content',array('id_content'=>$id));
            return $query;
        }
        function update_content($data,$id){
            return $this->db->update('content',$data,array('id_content'=>$id));
        }
        function activate_new($id){
            return $this->db->update('content',array('is_paid'=>1),array('id_content'=>$id));
        }
        function deactivate_new($id){
            return $this->db->update('content',array('is_paid'=>0),array('id_content'=>$id));
        }
    }
?>
